<template>
    <div class="home-input">
        <van-search v-model="value" placeholder="请输入搜索关键词" input-align="center" shape="round" @search="onSearch"/>
    </div>
</template>


<script>
import { betterScrollHorizontal } from '../../common/betterScroll.js'
import { Toast } from 'vant';

export default {
    data() {
        return {
            value: '',
            searchData: [],
        };
    },
    created() {
        this.getSearchList(this.value);
    },
    methods: {
        //获取搜索数据
        getSearchList(){
            this.$request("get", "/search/default", {
                // id: this.$route.params.id
                keywords: this.$route.value
            })
            .then(res => {
                    console.log(res)
                    this.searchData = res.data
                    // console.log(this.searchData)
                    //异步数据的处理
                    betterScrollHorizontal(this, this.$refs.wrapper, this.$refs.content, this.searchData.length, 8)

                })
        },
        onSearch(val) {
            Toast(val);
        },
        onCancel() {
            Toast('取消');
        },
    }
};
</script>


<style scoped>
.home-input {
    margin-top: 3rem;
}
</style>